<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://unpkg.com/swiper@8.4.7/swiper-bundle.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            width: 100%;
            height: 100%;

        }

        .swiper {
            width: 100%;
            height: 100%;
            --swiper-theme-color: #ff6600;
            --swiper-pagination-color: #00ff33;
            --swiper-navigation-size: 10px;
        }
    </style>
</head>

<body>
    <div class="swiper">
        <div class="swiper-wrapper">
            <div style="background-color: aqua;" class="swiper-slide">Slide 1</div>
            <div style="background-color: orangered;" class="swiper-slide">Slide 2</div>
            <div style="background-color: palevioletred;" class="swiper-slide">Slide 3</div>
            <div style="background-color: rgb(153, 159, 159);" class="swiper-slide">Slide 4</div>
            <div style="background-color: yellowgreen;" class="swiper-slide">Slide 5</div>
        </div>
        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>

        <!-- 如果需要导航按钮 -->
        <div class="swiper-button-prev"></div>
        <div class="swiper-button-next"></div>

        <!-- 如果需要滚动条 -->
        <div class="swiper-scrollbar"></div>
    </div>
    <script src="./swiper/swiper-bundle.min.js"></script>
    <script>
        var mySwiper = new Swiper('.swiper', {
            initialSlide: 2,
            direction: 'horizontal', // 切换方向 horizontal 水平
            // vertical 垂直
            speed: 2000,
            autoplay: true,//可选选项，自动滑动
            loop: false, // 循环模式选项
            grabCursor: true,
            slidesPerView: 3,
            centeredSlides: true,
            effect: 'coverflow',
            // 如果需要分页器
            pagination: {
                el: '.swiper-pagination',
            },

            // 如果需要前进后退按钮
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            },

            // 如果需要滚动条
            scrollbar: {
                el: '.swiper-scrollbar',
                draggable: true,
            },
            on: {
                // start 先弹框再切换 
                // end  先切换再弹框
                slideChangeTransitionEnd: function () {
                    alert(this.activeIndex);// 打印当前切换到那张图片了
                },
            },
        })        
    </script>
</body>

</html>